Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get only bindings related to source/destination when checking if bindings exists or has been changed #43

Merged
merged 1 commit into from
Mar 15, 2023

Conversation

avitsidis
Copy link

Hello @cyrilgdn,

In our rabbitmq setup we have some topic exchanges with thousands of bindings. Theses bindings are not managed by terraform but others are (exchange -> queue or exhange -> exchange bindings for example). Rabbitmq supports that amount of bindings quite well but the rabbitmq management api starts to be really slow to get the list of all bindings(GET /api/bindings/vhost).
We reached a point where we start to have timeouts when we do terraform plan on any terraform with a rabbitmq_binding ressource because the provider does the same call to detect if the binding already exist and if it needs to be updated.

After some investigations, the rabbitmq api does supports calls to specify the queue/exchanges involved in the binding(/api/bindings/vhost/e/source/e/destination and /api/bindings/vhost/e/exchange/q/queue). Replacing the get all binding api call (/api/bindings/vhost) by these, makes the call much lighter. Theses calls are implemented by ListExchangeBindingsBetween and ListQueueBindingsBetween in Rabbithole

This PR replace the 'list all bindings' call to more specific call depending on the destination type (queue or echange)

We did some tests in our setup and it seems to work nicely.

Note: I don't have experience in Go nor in terraform provider development, I'm open for any feedback/comment to improve the PR code to make better ;-)

Terraform Version

tested with terraform v1.0.3

Rabbitmq server version

3.8.21 (list all seems to be faster with higher version of rabbitmq server)

Affected Resource(s)

Please list the resources as a list, for example:

  • rabbitmq_binding

Debug Output

Error: unexpected EOF (due to the api call timeout)

Steps to Reproduce

  1. terraform plan

when checking if bindings exists or has been changed
@nico2610
Copy link

@cyrilgdn Is it possible to review and maybe merge this PR ? thanks in advance !

@avitsidis
Copy link
Author

hello @cyrilgdn, would it be possible to have a look at my PR please? Thanks in advance

Copy link
Owner

@cyrilgdn cyrilgdn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Thanks for your work and sorry for the delay.
The code looks good to me and if you tested it, we can merge 👍

@cyrilgdn cyrilgdn merged commit b739f27 into cyrilgdn:master Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants